package com.nf.health.app.adapter;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.nf.health.app.R;
import com.nf.health.app.models.SchemeAddVo;
import com.nf.health.app.models.SchemeVo;
import com.nf.health.app.utils.ImageLoaderUtils;
import com.nf.health.app.utils.Util;

import java.util.List;

/**
 * Created by Administrator on 2016/3/22.
 */
public class SchemeSystemAdapter extends BaseAdapter{
    List<SchemeAddVo> newsList;
    Activity activity;
    LayoutInflater inflater = null;
    public SchemeSystemAdapter(Activity activity, List<SchemeAddVo> newsList) {
        this.activity = activity;
        this.newsList = newsList;
        inflater = LayoutInflater.from(activity);
    }
    @Override
    public int getCount() {
        return newsList == null ? 0 : newsList.size();
    }

    @Override
    public Object getItem(int position) {
        if (newsList != null && newsList.size() != 0) {
            return newsList.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SchemeAddVo item = newsList.get(position);
        ViewHolder holder;

            holder = ViewHolder.get(parent, convertView, R.layout.item_system_scheme, position);
            ImageView iv_user_head_icon = holder.getView(R.id.scheme_image);
            ImageLoaderUtils.getinstance(activity).getImage(iv_user_head_icon, item.getImgurl(), R.drawable.default_image);
            holder.setText(R.id.tv_name, item.getName());
            holder.setText(R.id.tv_var, item.getPeoplenum()+"人加入该计划");

        return holder.getConvertView();
    }
}
